/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WidokWczytajTransport.java
 *
 * Created on 2011-07-19, 19:53:07
 */

package App.widoki;

import App.kontrolery.KontrolerWczytajTransport;
import App.modele.ModelWczytajTransport;
import java.util.Date;

/**
 *
 * @author Krzysiek
 */
public class WidokWczytajTransport extends javax.swing.JFrame {

    /** Creates new form WidokWczytajTransport */
    KontrolerWczytajTransport kontroler = null;
    ModelWczytajTransport model = null;
    //**************************************************************************
    public WidokWczytajTransport(KontrolerWczytajTransport kontroler, ModelWczytajTransport model)
    {
        this.kontroler = kontroler;
        this.model = model;
        initComponents();
    }

    public void dodajHistorieWczytywania(String opis)
    {
        String header = new Date().toString() + " : " +"Wczytano nowe dane \n\n";
        jTextPaneOpisTransportu.setText(header + opis);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButtonWybierzSciezke = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jButtonWczytaj = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneOpisTransportu = new javax.swing.JTextPane();
        jButtonZapiszTransport = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jButtonWybierzSciezke.setText("Wybierz plik");
        jButtonWybierzSciezke.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonWybierzSciezkeActionPerformed(evt);
            }
        });

        jTextField1.setText("Nie wybrano pliku ...");

        jButtonWczytaj.setText("Wczytaj transport z wybranego pliku");
        jButtonWczytaj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonWczytajActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(jTextPaneOpisTransportu);

        jScrollPane2.setViewportView(jScrollPane1);

        jButtonZapiszTransport.setText("Zapisz wczytany transport jako planowane działania");
        jButtonZapiszTransport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonZapiszTransportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
                    .addComponent(jButtonWczytaj, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonWybierzSciezke)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE))
                    .addComponent(jButtonZapiszTransport, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonWybierzSciezke)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonWczytaj)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonZapiszTransport)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonWybierzSciezkeActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonWybierzSciezkeActionPerformed
    {//GEN-HEADEREND:event_jButtonWybierzSciezkeActionPerformed
        kontroler.wybierzPlik();
    }//GEN-LAST:event_jButtonWybierzSciezkeActionPerformed

    private void jButtonWczytajActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonWczytajActionPerformed
    {//GEN-HEADEREND:event_jButtonWczytajActionPerformed
        kontroler.wczytajTransport();
    }//GEN-LAST:event_jButtonWczytajActionPerformed

    private void jButtonZapiszTransportActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonZapiszTransportActionPerformed
    {//GEN-HEADEREND:event_jButtonZapiszTransportActionPerformed
        kontroler.dodajTransport();
    }//GEN-LAST:event_jButtonZapiszTransportActionPerformed

    public void ustawSciezke(String sciezka)
    {
        this.jTextField1.setText(sciezka);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //new WidokWczytajTransport().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonWczytaj;
    private javax.swing.JButton jButtonWybierzSciezke;
    private javax.swing.JButton jButtonZapiszTransport;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextPane jTextPaneOpisTransportu;
    // End of variables declaration//GEN-END:variables

}
